//
//  SimpleImageOperation.m
//  SimpleWebImage
//
//  Created by Jiang on 2019/8/26.
//  Copyright © 2019 SilverFruity. All rights reserved.
//

#import "SimpleImageOperation.h"

@implementation SimpleImageOperation

@end

@implementation SimpleImageOperationPool
- (instancetype)init
{
    self = [super init];
    self.operationCache = [NSMutableDictionary dictionary];
    return self;
}
- (void)addOperation:(SimpleImageOperation *)operation forKey:(NSString *)key{
    @synchronized (self) {
        NSMutableArray *ops = self.operationCache[key];
        if (ops) {
            [ops addObject:operation];
        }else{
            self.operationCache[key]  = [@[operation] mutableCopy];
        }
    }
}
- (void)removeAllOperationsForKey:(NSString *)key{
    self.operationCache[key] = [NSMutableArray array];
}
- (NSArray<SimpleImageOperation *> *)operationsForKey:(NSString *)key{
    @synchronized (self) {
        return [self.operationCache[key] copy];
    }
}

@end
